asm
  ld sp,$CFFF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $C010
dim seed as uinteger at $C012
dim ee0 as uinteger at $C014
dim ee1 as uinteger at $C016
dim ee2 as uinteger at $C018
dim ee3 as uinteger at $C01A
dim eex as uinteger at $C01C
dim eey as uinteger at $C01E

seed=0

sub fightingrollerputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte):
  poke $E000+(31-typ1)+(31-txp1)*32,tch1
  end sub

sub fightingrollerputattr(typ1 as uinteger,tvl1 as ubyte):
  poke $E401+(31-typ1)*2,tvl1
  end sub

sub fightingrollerscroll(typ1 as uinteger,tvl1 as ubyte):
  poke $E400+(31-typ1)*2,tvl1
  end sub

'sub fightingrollerputsprite(tly2 as uinteger,txp2 as ubyte,typ2 as ubyte,tch2 as ubyte,tat2 as ubyte)
'  end sub



for ee0=0 to 31
  for ee1=0 to 31
    seed=smsrnd(seed)
    fightingrollerputchar(ee1,ee0,seed band 7)
    smsdelay(100)
    next:next

for ee0=0 to 31
    seed=smsrnd(seed)
    fightingrollerputattr(ee0,seed)
    smsdelay(500)
    next

for ee0=0 to 15
  for ee1=0 to 15
    fightingrollerputchar(ee1+13,ee0+13,ee0*16+ee1)
    smsdelay(200)
    next:next


eee=0:eex=8:eey=8
do

fightingrollerputchar(3,1,48+(int(eee/100) mod 10))
fightingrollerputchar(4,1,48+(int(eee/10) mod 10))
fightingrollerputchar(5,1,48+(eee mod 10))

ee0=peek($F800)
fightingrollerputchar(3,3,48+(int(ee0/100) mod 10))
fightingrollerputchar(4,3,48+(int(ee0/10) mod 10))
fightingrollerputchar(5,3,48+(ee0 mod 10))
eex=eex-((ee0 band 1)/1)+((ee0 band 2)/2)
eey=eey-((ee0 band 4)/4)+((ee0 band 8)/8)

ee0=peek($F801)
fightingrollerputchar(3,4,48+(int(ee0/100) mod 10))
fightingrollerputchar(4,4,48+(int(ee0/10) mod 10))
fightingrollerputchar(5,4,48+(ee0 mod 10))

ee0=peek($F804)
fightingrollerputchar(3,5,48+(int(ee0/100) mod 10))
fightingrollerputchar(4,5,48+(int(ee0/10) mod 10))
fightingrollerputchar(5,5,48+(ee0 mod 10))

ee0=peek($F805)
fightingrollerputchar(3,6,48+(int(ee0/100) mod 10))
fightingrollerputchar(4,6,48+(int(ee0/10) mod 10))
fightingrollerputchar(5,6,48+(ee0 mod 10))



fightingrollerputchar(eex,eey,eee band 127)

smsdelay(5000):eee=eee+1
loop

'-------------------------------


do:loop

do

for ee0=0 to 31
  for ee1=0 to 31
    seed=smsrnd(seed)
    fightingrollerputchar(ee1,ee0,seed)
    smsdelay(1000)
    next:next

for ee0=0 to 31
    seed=smsrnd(seed)
    fightingrollerputattr(ee0,seed)
    smsdelay(8000)
    next

for ee0=0 to 31
    seed=smsrnd(seed)
    fightingrollerscroll(ee0,seed)
    smsdelay(8000)
    next



'for ee2=$E400 to $E43F step 2 '-color -y scroll
'  seed=smsrnd(seed)
'  poke ee2,seed
'  smsdelay(8000)
'  next

'for ee2=$E401 to $E43F step 2 '-color -y attr?
'  seed=smsrnd(seed)
'  poke ee2,seed
'  smsdelay(8000)
'  next

for ee2=$F000 to $F0FF '-sprite 
  seed=smsrnd(seed)
  poke ee2,seed
  smsdelay(2000)
  next

loop

do:loop



'static ADDRESS_MAP_START( rollrace_map, AS_PROGRAM, 8, rollrace_state )
'AM_RANGE(0x0000, 0x7fff) AM_ROM
'AM_RANGE(0x8000, 0x9fff) AM_ROM          /* only rollace2 */
'AM_RANGE(0xc000, 0xcfff) AM_RAM
'AM_RANGE(0xd806, 0xd806) AM_READNOP /* looks like a watchdog, bit4 checked*/
'AM_RANGE(0xd900, 0xd900) AM_READWRITE(fake_d800_r,fake_d800_w) /* protection ??*/
'AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_SHARE("videoram")
'AM_RANGE(0xe400, 0xe47f) AM_RAM AM_SHARE("colorram")
'AM_RANGE(0xe800, 0xe800) AM_WRITE(soundlatch_byte_w)
'AM_RANGE(0xec00, 0xec0f) AM_NOP /* Analog sound effects ?? ec00 sound enable ?*/
'AM_RANGE(0xf000, 0xf0ff) AM_RAM AM_SHARE("spriteram")
'AM_RANGE(0xf400, 0xf400) AM_WRITE(backgroundcolor_w)
'AM_RANGE(0xf800, 0xf800) AM_READ_PORT("P1")
'AM_RANGE(0xf801, 0xf801) AM_READ_PORT("P2") AM_WRITE(bkgpen_w)
'AM_RANGE(0xf802, 0xf802) AM_READ_PORT("SYSTEM") AM_WRITE(backgroundpage_w)
'AM_RANGE(0xf803, 0xf803) AM_WRITE(flipy_w)
'AM_RANGE(0xf804, 0xf804) AM_READ_PORT("DSW1")
'AM_RANGE(0xf805, 0xf805) AM_READ_PORT("DSW2")
'AM_RANGE(0xfc00, 0xfc00) AM_WRITE(flipx_w)
'AM_RANGE(0xfc01, 0xfc01) AM_WRITE(nmi_mask_w)
'AM_RANGE(0xfc02, 0xfc03) AM_WRITENOP /* coin counters */
'AM_RANGE(0xfc04, 0xfc05) AM_WRITE(charbank_w)
'AM_RANGE(0xfc06, 0xfc06) AM_WRITE(spritebank_w)
'ADDRESS_MAP_END


